<template>
	<!-- 车辆交接记录 未完成 -->
	<div class="content">
		<div class="content-top">
			车辆管理_车辆交接记录
		</div>
		<div class="content-operation">
		</div>
		<div class="content-search">
			<!-- <el-form :inline="true"  class="demo-form-inline" style="margin-top: 20px;">
        <el-form-item label="企业名称">
          <el-input  placeholder="企业名称"></el-input>
        </el-form-item>
         <el-form-item label="企业名称">
           <el-input  placeholder="企业名称"></el-input>
         </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search">搜索</el-button>
        </el-form-item>
      </el-form> -->
		</div>
		<div class="content-table">
			<el-table :data="tableData" show-header stripe style="width: 100%;">
				<el-table-column prop="carLicensePlateNumber" label="车牌号" width="100">
				</el-table-column>
				
				<el-table-column prop="carVin" label="车架号" width="200">
				</el-table-column>
				<el-table-column prop="memberName" label="用户姓名" width="100">
				</el-table-column>
				<el-table-column prop="nextMemberName" label="交接用户姓名" width="200">
				</el-table-column>
				<el-table-column prop="handOverTime" label="本车交班时间" width="200">
				</el-table-column>
				<el-table-column prop="closingTime" label="下班时间" width="200">
				</el-table-column>
				<el-table-column prop="drivingMileage" label="行驶里程" width="120">
				</el-table-column>

				
				<el-table-column prop="nowHandOverMileage" label="当前车辆里程" width="200">
				</el-table-column>
				<el-table-column prop="preHandOverMileage" label="交班前车辆里程" width="200">
				</el-table-column>
				
				<el-table-column fixed="right" label="操作" width="100">
					<template slot-scope="scope">
						<el-button @click="handleClick(scope.row)" type="text" size="small"><span><i class="el-icon-s-order"></i>交接历史</span></el-button>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<div class="content-page">
			<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="page"
			 :page-size=limit layout="prev, pager, next, jumper" :total=total>
			</el-pagination>
		</div>
		
		<template v-if="is_history">
			<div class="all-screen"></div>
			<div class='history-box'>
				<CarHistory @saveHistory='saveHistory' :id='id' ></CarHistory>
			</div>
		</template>

	</div>
</template>

<script>
	import Global from '@/components/Global.vue'
	import CarHistory from '@/components/car/CarHistory.vue'
	export default {
		components: {
			CarHistory:CarHistory,
		},

		data() {
			return {
				id: 'id',
				status: '',
				is_add: false,
				is_edit: false,
				is_history:false,
				tableData: [],
				limit: 10,
				page: 1,
				total: 1,
				dict: '',

				tableData: []
			}
		},
		mounted() {
			this.get_dict();
			this.get_list();
		},
		methods: {
			get_dict() {
				var self = this;
				this.$axios.get(this.$global.serverIp + 'admin/dict/findDict?keyword=vehicle')
				  .then(function (res) {
					  if(res != '')
						self.dict = res.data;
				  })
			},
			get_list() {
				var self = this;
				this.$axios.post(this.$global.serverIp + 'vehicle/handover/findPage', {
				"limit": self.limit + "",
				"page": self.page + ""
				  })
				  .then(function (res) {
					  if(res != ''){
						 self.tableData = res.data.list;
						 self.total = res.data.totalCount;
						 self.page = res.data.currPage;
					  }
						
				  })
			
			},
			handleSizeChange(val) {
				console.log(`每页 ${val} 条`);
			},
			handleCurrentChange(val) {
				this.page = val;
				this.get_list();
				console.log(`当前页: ${val}`);
			},
			
			saveEdit(type) {
				if (type == 2) {
					this.get_list();
				}
				this.is_edit = false;
			},
			saveHistory(){
				this.is_history = false;
			},
			editCompany() {
				this.is_history = true;
			},
			handleClick(row) {
				console.log(row.id);
				this.id = row.id;
				this.status = row.status;
				this.editCompany();
			}
		},


	}
	import '@/assets/css/common.css'
</script>
